<html>
<head>

    <style type="text/css">
        .htmltorss {

        }
        .highlight {
            border-style: double;
            border-width: 3px;
            border-color: black;
        }


    </style>
    <script type="text/javascript" src="browser_detect.js"></script>
    <script type="text/javascript">

        const $$$HTML_TO_RSS_ID = "__htmltorss_id__";
        var $$$selected = new Array();
        var $$$current = null;

        function $$$onClick (event) {
            event = $$$getEvent(event);
            $$$toggle($$$getTarget(event));
        }

        function $$$isIndexedTag(target ) {
            if (target.getAttribute($$$HTML_TO_RSS_ID)) return true; else return false;
        }

        function $$$toggle(target) {
            if (!$$$isIndexedTag(target)) {
                return ;
            }
            if ($$$contains($$$selected, target)) {
                $$$removeTarget($$$selected, target);
                target.className="";
            } else {
                $$$addTarget($$$selected, target);
            }
            $$$refreshDisplay();
        }

        function $$$refreshDisplay() {
            for (var i=0; i<$$$selected.length; i++) {
                var a = $$$selected[i];
                a.className="highlight";
            }
        }

        function $$$removeTarget(where, what) {
            var i = $$$position(where, what);
            if (i == where.length -1) {
                where.pop();
            } else {
                where.splice(i, 1);
            }
        }

        function $$$addTarget(where, what) {
            where.push(what);
        }

        function $$$contains(where, what) {
            return $$$position(where,what) > -1;
        }

        function $$$position(where, what) {
            var i=0;
            for (i=0; i<where.length; i++) {
                var a = where[i];
                if (a.getAttribute($$$HTML_TO_RSS_ID) == what.getAttribute($$$HTML_TO_RSS_ID)) {
                    return i;
                }
                i++;
            }
            return -1;
        }

        function $$$getTarget(event) {
            if (is_ie4up) {
                return event.srcElement;
            } else {
                return event.target;
            }
        }

        function $$$getEvent(event) {
            if (is_ie4up) {
                return window.event;
            } else {
                return event;
            }
        }

        function $$$onMouseOver(event)
        {
            event = $$$getEvent(event);
            if ($$$getTarget(event) != $$$current) {
                if ($$$current != null) {
                    $$$current.className = "";
                }
            }
            $$$current = $$$getTarget(event);
            if ($$$isIndexedTag($$$current)) {
                $$$current.className = "highlight";
                $$$log($$$current);
            }
            if (is_gecko) {
                event.stopPropagation();
                event.preventDefault();
            }
            $$$refreshDisplay();
            return false;
        }

        function $$$initEvents() {
            if (is_ie4up) {
                document.onmouseover = $$$onMouseOver;
                document.onclick = $$$onClick;
            } else {
                document.addEventListener("mouseover", $$$onMouseOver, true);
                document.addEventListener("click", $$$onClick, true);
            }
        }

        function $$$finish() {
            if ($$$current!=null) {
                var result = "";
                for (var i=0; i<$$$selected.length; i++) {
                    result += $$$selected[i].getAttribute($$$HTML_TO_RSS_ID)+" ";
                }
                window.alert(result);
            }
        }

        function $$$log() {
            if (is_gecko) {
                console.log($$$current);
            }
        }

        window.onload=$$$initEvents;

        window.onunload = function (event) {
            event.
//            event = $$$getEvent(event);
//            event.returnValue = "All your work will be lost.";
//            event.returnValue = false;
            return false;
        }

    </script>
</head>
<body>
<p id="p1" __htmltorss_id__="1" >test1</p>

<p id="p2" __htmltorss_id__="2" >test2</p>

<button type="button" onclick="$$$finish()"  >finish</button>

</body>
</html>